//
//  BDMalAddressTableViewCell.m
//  BadBoy
//
//  Created by wen on 2017/5/6.
//  Copyright © 2017年 com.8xiong. All rights reserved.
//

#import "BDMalAddressTableViewCell.h"
#import "BDUserAddressModel.h"
@interface BDMalAddressTableViewCell ()

@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *phoneLabel;
@property (nonatomic, strong) UILabel *addressLabel;

@end

@implementation BDMalAddressTableViewCell

- (void)configeWithModel:(id)model{
    if ([model isKindOfClass:[BDUserAddressModel class]]) {
        BDUserAddressModel *addressModel = model;
        self.nameLabel.text = addressModel.name;
        self.phoneLabel.text = addressModel.mobile;
        self.addressLabel.text = [addressModel.cityStr stringByAppendingString:addressModel.address];
    }else{
        self.nameLabel.text = ASLocalizedString(@"当前没有默认地址");
        self.addressLabel.text = ASLocalizedString(@"点击前往选择地址");
    }
    
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    self.nameLabel.font = [UIFont systemFontOfSize:14];
    self.nameLabel.textColor = [UIColor colorWithHexString:@"#4c4c4c"];
    [self.nameLabel sizeToFit];
    self.nameLabel.left = 10;
    self.nameLabel.top = 15;
    
    self.phoneLabel.font = [UIFont systemFontOfSize:14];
    self.phoneLabel.textColor = [UIColor colorWithHexString:@"#1c1c1c"];
    [self.phoneLabel sizeToFit];
    self.phoneLabel.left = self.nameLabel.right + 20;
    self.phoneLabel.centerY = self.nameLabel.centerY;
    
    self.addressLabel.font = [UIFont systemFontOfSize:13];
    self.addressLabel.textColor = [UIColor colorWithHexString:@"#767676"];
    self.addressLabel.numberOfLines = 0;
    self.addressLabel.width = self.width - 40;
    [self.addressLabel sizeToFit];
    self.addressLabel.left = 10;
    self.addressLabel.bottom = self.height - 15;
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}


- (UILabel *)nameLabel{
    if (!_nameLabel) {
        self.nameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_nameLabel];
    }
    return _nameLabel;
}

- (UILabel *)phoneLabel{
    if (!_phoneLabel) {
        self.phoneLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_phoneLabel];
    }
    return _phoneLabel;
}

- (UILabel *)addressLabel{
    if (!_addressLabel) {
        self.addressLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_addressLabel];
    }
    return _addressLabel;
}


@end
